package com.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.exception.LMSException;

//AUTHOR-SATHISH
/**
 * The Class ConnectionCloser.
 * 
 * @author : gbs02399 Created on : Jul 6, 2012 Project : LMS File Name :
 *         ConnectionCloser.java
 */
public class ConnectionCloser {

	/**
	 * Close connection.
	 * 
	 * @param resultSet
	 *            the result set
	 * @param connection
	 *            the connection
	 * @param preparedStatement
	 *            the prepared statement
	 * @throws LMSException
	 *             the lMS exception
	 */
	public static void closeConnection(final ResultSet resultSet,
			final Connection connection,
			final PreparedStatement preparedStatement) throws LMSException {
		try {
			if (resultSet != null) {
				resultSet.close();
			}
			if (preparedStatement != null) {
				preparedStatement.close();
			}
			if (connection != null) {
				connection.close();
			}
		} catch (final SQLException e) {
			e.printStackTrace();
			throw new LMSException(e.getMessage());
		}
	}
}
